package com.frskycockpit.activity;

import java.util.List;

import com.frskycockpit.R;

import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;

public class SettingsActivity extends PreferenceActivity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}

	@Override
	public void onBuildHeaders(List<Header> target) {
		loadHeadersFromResource(R.xml.settings_header, target);
	}

	public static class SettingsGenericFragment extends PreferenceFragment {
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			PreferenceManager.setDefaultValues(getActivity(),
					R.xml.settings_generic, false);
			addPreferencesFromResource(R.xml.settings_generic);
		}

		@Override
		public void onResume() {
			super.onResume();
		}
	}

	public static class SettingsLogdataFragment extends PreferenceFragment {
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			PreferenceManager.setDefaultValues(getActivity(),
					R.xml.settings_logdata, false);
			addPreferencesFromResource(R.xml.settings_logdata);
		}

		@Override
		public void onResume() {
			super.onResume();
		}
	}

	public static class SettingsApplicationFragment extends PreferenceFragment {
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			PreferenceManager.setDefaultValues(getActivity(),
					R.xml.settings_application, false);
			addPreferencesFromResource(R.xml.settings_application);
		}

		@Override
		public void onResume() {
			super.onResume();
		}
	}

    //@TargetApi(Build.VERSION_CODES.HONEYCOMB)
    //@Override
	protected boolean isValidFragment(String fragmentName) {
		if (SettingsGenericFragment.class.getName().equals(fragmentName))
			return true;
		if (SettingsLogdataFragment.class.getName().equals(fragmentName))
			return true;
		if (SettingsApplicationFragment.class.getName().equals(fragmentName))
			return true;
		return false;//super.isValidFragment(fragmentName);
	}
}
